home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / public / plan / src / cal.h < prev    next >
C/C++ Source or Header  |  1994-08-01  |  10KB  |  252 lines

  1. /*
  2.  * everything the main program needs but the daemon doesn't. This mainly
  3.  * means X stuff to keep the size of the daemon down.
  4.  */
  5.  
  6. #include "conf.h"
  7.  
  8. struct mainmenu {        /* all important main window widgets */
  9.     Widget    month;            /* main window: month name label */
  10.     Widget    year;            /* main window: year number label */
  11.     Widget    time;            /* main window: time display label */
  12.     Widget    cal;            /* main window: calendar drawing area*/
  13.     Widget    yearcal;        /* year window: calendar drawing area*/
  14.     Widget    weekcal;        /* week window: calendar drawing area*/
  15. };
  16.  
  17.  
  18.                 /* when writing database files, write what? */
  19. #define WR_CONFIG    1        /* configuration & preferences */
  20. #define WR_PUBLIC    2        /* entries readable by everybody */
  21. #define WR_PRIVATE    4        /* entries readable by owner only */
  22.  
  23.  
  24. /*
  25.  * everything about a list popup. time, period, and key describe what is
  26.  * listed in the menu:
  27.  *
  28.  * time=0, period=0, key=0:        the entire list
  29.  * time=0, period=0, key=string:    all entries that contain <key>
  30.  * time>0, period=0, key=X:        one day only
  31.  * time>0, period>1, key=X:        <period/86400> days
  32.  *
  33.  * The sublist field contains an array of pointers being displayed in the
  34.  * menu. It is created by create_sublist(). listmenu.sublist->nentries is
  35.  * the number of entries being displayed in the menu, which is always
  36.  * less than listmenu.nentries, which is the number of button rows.
  37.  */
  38.  
  39.                 /* button columns in day schedule list */
  40. #define SC_ENABLE    0        /* radio button to enable */
  41. #define SC_DATE        1        /* date */
  42. #define SC_TIME        2        /* time */
  43. #define SC_LENGTH    3        /* length */
  44. #define SC_FLAGS    4        /* first flag (same order as PIC_*) */
  45. #define SC_ADVANCE    4        /*   advance-warning flag */
  46. #define SC_RECYCLE    5        /*   repeat flag */
  47. #define SC_MESSAGE    6        /*   show-message flag */
  48. #define SC_SCRIPT    7        /*   execute-script flag */
  49. #define SC_MEETING    8        /*   meeting flag */
  50. #define SC_PRIVATE    9        /*   keep-private flag */
  51. #define SC_NOTE        10        /* short note for calendar */
  52. #define SC_N        11        /* # of columns */
  53.  
  54.  
  55. struct listmenu {        /* all important list popup widgets */
  56.     struct listmenu *next, *prev;    /* if there are multiple list popups */
  57.     BOOL    popped;            /* TRUE if the menu is accessible */
  58.     BOOL    valid;            /* TRUE if the widgets exist */
  59.     BOOL    pinned;            /* TRUE if popup can't be re-used */
  60.     struct    sublist *sublist;    /* sublist with live entry ptrs */
  61.     time_t    time;            /* if nonzero, first day in list */
  62.     time_t    period;            /* if nonzero, how many days */
  63.     char    *key;            /* if nonzero, this is a keyword list*/
  64.     struct    entry *oneentry;    /* if nonzero, this one entry only */
  65.     Widget    shell;            /* the popup menu itself */
  66.     Widget    title;            /* title string */
  67.     Widget    confirm, undo;        /* buttons */
  68.     Widget    dup, del, done, pin;    /* more buttons */
  69.     Widget    list;            /* RowColumn widget for entry list */
  70.     Widget    (*entry)[SC_N];        /* each entry has SC_N columns */
  71.     Widget    text;            /* if in text input mode, Text widget*/
  72.     int    nentries;        /* how many rows, multiple of 5 */
  73.     int    xedit, yedit;        /* row/col being edited if .text!=0 */
  74. };
  75.  
  76.  
  77. /*
  78.  * when the user is entering a new entry or changing an existing one, all
  79.  * the new data goes into this struct only. This struct "overlays" the
  80.  * real entry until editing is undone or confirmed.
  81.  */
  82.  
  83. struct edit {
  84.     BOOL        editing;    /* new_entry is being edited */
  85.     BOOL        changed;    /* new entry is valid, needs confirm */
  86.     struct entry    entry;        /* buffer for entry being edited */
  87.     int        y;        /* row# of new entry, > 0 */
  88.     struct listmenu    *menu;        /* ptr to listmenu with new entry */
  89. };
  90.  
  91.  
  92. /*
  93.  * holiday struct. There are several of these, for holidays, vacations, and
  94.  * birthdays. To keep it simple, all three lists use the same struct. There
  95.  * is one struct for each day; if its "string" pointer is nonzero, the
  96.  * holiday or whatever exists and must be put in the day box. If <dup> is
  97.  * true, the struct is a duplicate of some other struct; its <string> must
  98.  * not be free()d (this happens for vacations, which are typically longer
  99.  * than one day, even in the US).
  100.  */
  101.  
  102. struct holiday {
  103.     char        *string;    /* name of holiday, 0=not a holiday */
  104.     int        stringcolor;    /* 0=default, 1..8=black..white */
  105.     int        daycolor;    /* 0=default, 1..8=black..white */
  106.     BOOL        dup;        /* this is a clone of 1st vacatn day */
  107. };
  108.  
  109.  
  110. /*
  111.  * Node of the trees that control the arrangement of entries in the week
  112.  * view. There is one tree per day. Consecutive nonoverlapping entries are
  113.  * chained with next/prev; lines are chained by up/down in the first node.
  114.  */
  115.  
  116. #define NDAYS        7        /* # of days in a week view */
  117.  
  118. struct weeknode {
  119.     struct weeknode    *next;        /* next entry to the right */
  120.     struct weeknode    *prev;        /* next entry to the left */
  121.     struct weeknode    *up;        /* if !*prev, first in prev line */
  122.     struct weeknode    *down;        /* if !*prev, first in next line */
  123.     struct entry    *entry;        /* entry being described */
  124.     time_t        trigger;    /* real trigger time for this bar */
  125.     char        text[80];    /* note text */
  126.     int        textlen;    /* length of text in pixels */
  127.     BOOL        textinside;    /* TRUE if text fits in bar */
  128.     struct user    *user;        /* whose entry; 0=our own */
  129. };
  130.  
  131. struct week {
  132.     struct weeknode    *tree[NDAYS];    /* anchors for all days */
  133.     int        nlines[NDAYS];    /* # of lines, min 1, 0=not in year */
  134.     int        canvas_xs;    /* drawing area width */
  135.     int        canvas_ys;    /* drawing area height */
  136.     Widget        canvas;        /* drawing area widget */
  137.     Widget        scroll;        /* scrolling widget around canvas */
  138.     Widget        info;        /* info text line */
  139. };
  140.  
  141.  
  142. /*
  143.  * X stuff
  144.  */
  145.  
  146.                 /* fonts */
  147. #define FONT_STD    0        /* standard font: menus, text */
  148. #define FONT_HELP    1        /* pretty font for help popups */
  149. #define FONT_DAY    2        /* month view: large day #s */
  150. #define FONT_SMDAY    3        /* small month view: large day #s */
  151. #define FONT_NOTE    4        /* month view: small notes */
  152. #define FONT_YTITLE    5        /* year view: title string */
  153. #define FONT_YMONTH    6        /* year view: month names */
  154. #define FONT_YDAY    7        /* year view: weekday names */
  155. #define FONT_YNUM    8        /* year view: day numbers */
  156. #define FONT_WTITLE    9        /* week view: title string */
  157. #define FONT_WDAY    10        /* week view: weekday column */
  158. #define FONT_WHOUR    11        /* week view: hour row */
  159. #define FONT_WNOTE    12        /* week view: small notes */
  160. #define FONT_JNOTE    13        /* Japanese font for all the notes */
  161. #define NFONTS        14
  162.  
  163.                 /* colors */
  164. #define COL_BACK    0        /* standard background */
  165. #define COL_STD        1        /* standard foreground */
  166. #define COL_CALBACK    2        /* calendar background */
  167. #define COL_CALACT    3        /* calendar background for active day*/
  168. #define COL_CALTODAY    4        /* calendar background for active day*/
  169. #define COL_CALSHADE    5        /* calendar daybox background */
  170. #define COL_CALFRAME    6        /* calendar frame around all days */
  171. #define COL_GRID    7        /* calendar grid lines */
  172. #define COL_WEEKDAY    8        /* calendar weekday number */
  173. #define COL_WEEKEND    9        /* calendar holiday number */
  174. #define COL_NOTE    10        /* calendar weekday note text */
  175. #define COL_NOTEOFF    11        /* calendar weekday note if suspended*/
  176. #define COL_TOGGLE    12        /* schedule enable toggle button */
  177. #define COL_RED        13        /* schedule pin toggle button */
  178. #define COL_TEXTBACK    14        /* standard bkground of text widgets */
  179. #define COL_YBACK    15        /* year view background */
  180. #define COL_YBOXBACK    16        /* year view bkgd of month boxes */
  181. #define COL_YNUMBER    17        /* year view day numbers */
  182. #define COL_YWEEKDAY    18        /* year view weekday names */
  183. #define COL_YMONTH    19        /* year view month names */
  184. #define COL_YTITLE    20        /* year view title */
  185. #define COL_YGRID    21        /* year view month box lines */
  186. #define COL_HBLACK    22        /* holiday day or text */
  187. #define COL_HRED    23        /* holiday day or text */
  188. #define COL_HGREEN    24        /* holiday day or text */
  189. #define COL_HYELLOW    25        /* holiday day or text */
  190. #define COL_HBLUE    26        /* holiday day or text */
  191. #define COL_HMAGENTA    27        /* holiday day or text */
  192. #define COL_HCYAN    28        /* holiday day or text */
  193. #define COL_HWHITE    29        /* holiday day or text */
  194. #define COL_WBACK    30        /* week view background */
  195. #define COL_WBOXBACK    31        /* week view bar box background */
  196. #define COL_WTITLE    32        /* week view title string */
  197. #define COL_WGRID    33        /* week view fat and fine grid */
  198. #define COL_WDAY    34        /* week view week day and hour texts */
  199. #define COL_WNOTE    35        /* week view note text in bars */
  200. #define COL_WFRAME    36        /* week view frame around bars */
  201. #define COL_WWARN    37        /* week view shading of warning bars */
  202. #define COL_WUSER_0    38        /* week view shading of user 0 bars */
  203. #define COL_WUSER_1    39        /* week view shading of user 1 bars */
  204. #define COL_WUSER_2    40        /* week view shading of user 2 bars */
  205. #define COL_WUSER_3    41        /* week view shading of user 3 bars */
  206. #define COL_WUSER_4    42        /* week view shading of user 4 bars */
  207. #define COL_WUSER_5    43        /* week view shading of user 5 bars */
  208. #define COL_WUSER_6    44        /* week view shading of user 6 bars */
  209. #define COL_WUSER_7    45        /* week view shading of user 7 bars */
  210. #define NCOLS        46
  211.  
  212.                 /* pixmaps. Don't re-order the first six */
  213. #define PIC_ADVANCE    0        /* schedule flag: advance warning */
  214. #define PIC_RECYCLE    1        /* schedule flag: repetitive */
  215. #define PIC_MESSAGE    2        /* schedule flag: has a message text */
  216. #define PIC_SCRIPT    3        /* schedule flag: has a shell script */
  217. #define PIC_MEETING    4        /* schedule flag: not used */
  218. #define PIC_PRIVATE    5        /* schedule flag: not used */
  219. #define PIC_BLANK    6        /* blank space (for inactive labels) */
  220. #define NPICS        7
  221.  
  222.  
  223. /*
  224.  * fix a Linux problem: most Done buttons crash plan, in XtDestroyWidget.
  225.  * Until somebody figures out why, this fixes it by introducing a huge
  226.  * memory leak.
  227.  */
  228.  
  229. #ifdef DESTROYBUG
  230. #define XTDESTROYWIDGET(w)
  231. #else
  232. #define XTDESTROYWIDGET(w) XtDestroyWidget(w)
  233. #endif
  234.  
  235.  
  236. /*
  237.  * Structure for partial strings of a mixed string, ascii and kanji
  238.  * characters.
  239.  */
  240.  
  241. #ifdef JAPAN
  242. #define MAXPARTIALSTRING    16
  243. #define MAXPARTIALCHAR        1024
  244.  
  245. typedef struct {
  246.     unsigned char    *strptr;    /* A pointer to a partial string. */
  247.     BOOL        asciistr;    /* True: a string is ascii. */
  248.     int        pixlen;        /* A length of a string in pixels. */
  249.     int        length;        /* A length of a string in bytes. */
  250. } strpack;
  251. #endif
  252.